<?php

/**
 * Class AccountController
 */
class AdminController extends BaseController
{
    /**
     * 登录
     * @author  fyl
     */
    public function Login(){
        return $this->view('admin.login');
    }

    /**
     * 登录请求
     * @author  fyl
     */
    public function DisposeLogin()
    {
        #接受参数
        $paramObj                   =          new stdClass();
        $paramObj->username         =          $this->getParam('username');          //用户名
        $paramObj->password         =          $this->getParam('password');          //密码
        $paramObj->captcha          =          $this->getParam('captcha');           //验证码

        try{
            AdminService::instance()->LoginValidator($paramObj);
            return Redirect::to('/ads_list');
        }catch (Exception $e){
            return Redirect::to('/');
        }
    }

    /**
     * 生成验证码
     * @author fyl
     * @date 2016-03-05
     */
    public function Captcha()
    {
        CaptchaService::instance()->create();
    }

    /**
     * 广告位列表
     * @return mixed
     */
    public function AdsList()
    {
        $info = AdminService::instance()->AdsList();
        return $this->view('admin.ads_list')->with('info',$info);
    }

    /**
     * 广告位录入
     * @return mixed
     */
    public function AddAds()
    {
        return $this->view('admin.add_ads');
    }

    /**
     * 广告位编辑
     * @return mixed
     */
    public function EditAds()
    {
        if (Request::isMethod('POST')) {
            #收集信息
            $paramObj = new stdClass();
            $paramObj->ads_id           = $this->getParam('ads_id');            //广告id
            $paramObj->ads_name         = $this->getParam('ads_name');          //广告名称
            $paramObj->img              = $this->getParam('img');               //图片
            $paramObj->img_old          = $this->getParam('img_old');           //图片
            $paramObj->type             = $this->getParam('type');              //广告类型
            $paramObj->is_rec           = $this->getParam('is_rec');            //是否推荐
            $paramObj->order_by         = $this->getParam('order_by');          //排序
            $paramObj->link             = $this->getParam('link');              //链接

            #逻辑操作
            empty($paramObj->ads_id) ?
                (AdminService::instance()->AdsAdd($paramObj).
                    LogService::instance()->write(['content' => '广告位添加'.$paramObj->ads_name, 'type' => '广告位服务'])):
                (AdminService::instance()->AdsUp($paramObj).
                    LogService::instance()->write(['content' => '广告位修改'.$paramObj->ads_name, 'type' => '广告位服务']));
            return Redirect::to('/ads_list');
        } else {
            $ads_id = $this->getParam('ads_id');
            $info = AdminService::instance()->GetAdsInfo($ads_id);
            return $this->view('admin.add_ads')->with('ads', $info);

        }
    }

    /**
     * 广告位删除
     */
    public function DelAds()
    {
        #收集信息
        $aData = new stdClass();
        $aData->ads_id = $this->getParam('ads_id');

        $ads_name = AdminService::instance()->GetAdsInfo($aData->ads_id)->ads_name;
        #逻辑操作
        $state = AdminService::instance()->DelAds($aData);
        LogService::instance()->write(['content' => '广告位删除'.$ads_name, 'type' => '广告位服务']);
        $this->rest->success(['state' => $state], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }
    public function AdsAjax()
    {
        $info = AdminService::instance()->AdsAjax();
        return $this->viewAjax('admin.ajaxTemplates.ads_list_part')->with('info', $info);
    }

    /**
     * 管理员管理
     * @return mixed
     * @author lzhp
     * @date 2016-04-04
     */
    public function ManageAdmin()
    {
        $info = AdminService::instance()->ManageAdmin();
        return $this->view('admin.manage_admin')->with('info', $info);
    }

    /**
     * 管理员添加
     * @return mixed
     * @author lzhp
     * @date 2016-04-04
     */
    public function AddAdmin()
    {
        return $this->view('admin.add_admin');
    }

    /**
     * 管理员编辑
     * @return mixed
     */
    public function EditAdmin()
    {

        if (Request::isMethod('POST')) {
            #收集信息
            $paramObj             = new stdClass();
            $paramObj->id         = $this->getParam('id');                 //ID
            $paramObj->name       = $this->getParam('name');               //姓名
            $paramObj->real_name  = $this->getParam('real_name');          //真名
            $paramObj->password   = $this->getParam('password');           //密码
            $paramObj->role_id    = $this->getParam('role_id');            //角色
            $paramObj->mobile     = $this->getParam('mobile');             //联系方式
            $paramObj->avatar     = $this->getParam('avatar');             //头像
            $paramObj->status     = $this->getParam('status');             //状态
            $paramObj->sure       = $this->getParam('sure');               //密码确认
            $paramObj->avatar_old = $this->getParam('avatar_old');


            #逻辑处理
            empty($paramObj->id) ?
                (AdminService::instance()->AdminAdd($paramObj).
                    LogService::instance()->write(['content' => '添加管理员'.$paramObj->name, 'type' => '管理员管理'])):
                (AdminService::instance()->AdminUp($paramObj).
                    LogService::instance()->write(['content' => '修改管理员'.$paramObj->name, 'type' => '管理员管理']));
            return Redirect::to('/manage_admin');
        } else {
            $id = $this->getParam('id');
            $info = AdminService::instance()->GetAdminInfo($id);
            return $this->view('admin.add_admin')->with('admin', $info);
        }
    }

    /**
     * 管理员删除
     */
    public function DeleteAdmin()
    {
        #收集信息
        $aData = new stdClass();
        $aData->id = $this->getParam('id');

        $name = AdminService::instance()->GetAdminInfo($aData->id)->name;
        #逻辑操作
        $state = AdminService::instance()->DeleteAdmin($aData);
        LogService::instance()->write(['content' => '删除管理员'.$name, 'type' => '管理员管理']);
        $this->rest->success(['state' => $state], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }

    /**
     * 管理员删除ajax返回
     */
    public function AdminServiceAjax()
    {
        $info = AdminService::instance()->ManageAdmin();
        return $this->viewAjax('admin.ajaxTemplates.admin_list_part')->with('info', $info);
    }

    //--------------------------------------产品---------------------------------------
    /**
     * 产品列表
     */
    public function ManageProject(){
        $info = AdminService::instance()->ManageProjectList();
        return $this->view('admin.manage_project')->with('info',$info);
    }

    /**
     * 产品录入
     */
    public function ManageProjectModify(){
        #接收参数
        $paramObj = new stdClass();
        $paramObj->project_id = $this->getParam('project_id');
        if(!empty($paramObj->project_id)){
            $info = AdminService::instance()->SelectOneProject($paramObj);
            return $this->view('admin.project_import')->with(["project"=>$info,"plate_type"=>ProjectEnum::$Plate_types,'ticket_type'=>ProjectEnum::$Ticket_types,'pay_type'=>ProjectEnum::$Pay_types]);
        }else{
            return $this->view('admin.project_import')->with(["plate_type"=>ProjectEnum::$Plate_types,'ticket_type'=>ProjectEnum::$Ticket_types,'pay_type'=>ProjectEnum::$Pay_types]);
        }
    }

    /**
     * 产品添加
     */
    public function AddManageProject(){
        if(Request::isMethod('POST')){
            #收集信息
            $paramObj                       = new stdClass();
            $paramObj->project_id           = $this->getParam('project_id');                   //ID
            $paramObj->project_name         = $this->getParam('project_name');                 //项目名称
            $paramObj->company_name         = $this->getParam('company_name');                 //公司名称
            $paramObj->project_scale        = $this->getParam('project_scale');                //项目规模
            $paramObj->yield_rate           = $this->getParam('yield_rate');                   //年收益率
            $paramObj->limit                = $this->getParam('limit');                        //项目期限
            $paramObj->pay_id               = $this->getParam('pay_id');                       //还款方式
            $paramObj->ticket_type          = $this->getParam('ticket_type');                  //票据种类
            $paramObj->type                 = $this->getParam('type');                         //1-上市通 2-央票通
            $paramObj->logo_img             = $this->getParam('logo_img');                     //项目logo
            $paramObj->status               = $this->getParam('status');                       //项目状态
            $paramObj->start_time           = $this->getParam('start_time');                   //开始时间
            $paramObj->old_img              = $this->getParam('old_img');                      //旧图片
            #逻辑处理
            empty($paramObj->project_id) ?
                (AdminService::instance()->AddManageProject($paramObj).
                    LogService::instance()->write(['content' => '添加项目'.$paramObj->project_name, 'type' => '产品管理'])):
                (AdminService::instance()->UpManageProject($paramObj).
                    LogService::instance()->write(['content' => '修改项目'.$paramObj->project_name, 'type' => '产品管理']));
            return Redirect::to('/manage_project');
        }

    }

    /**
     * 项目删除
     */
    public function DeleteManageProject()
    {
        #收集信息
        $paramObj = new stdClass();
        $paramObj->project_id = $this->getParam('project_id');
        $name = AdminService::instance()->SelectOneProject($paramObj)->project_name;
        #逻辑操作
        $state = AdminService::instance()->DeleteProject($paramObj->project_id);
        LogService::instance()->write(['content' => '删除产品'.$name, 'type' => '产品管理']);
        $this->rest->success(['state' => $state], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }

    /**
     * 项目删除ajax返回
     * @return mixed
     * @author fyl
     */
    public function AdminManageProjectAjax()
    {
        $info = AdminService::instance()->ManageProjectList();
        return $this->viewAjax('admin.ajaxTemplates.project_list_part')->with('info', $info);
    }


    /**
    --------------------------------------用户中心-------------------------------------
     */

    /**
     * 用户管理
     * @return mixed
     * @author lzhp
     * @date 2016-04-04
     */
    public function ManageUser()
    {
        $info = AdminService::instance()->ManageUser();
        return $this->view('admin.manage_user')->with('info', $info);
    }

    /**
     * 用户添加
     * @return mixed
     */
    public function AddUser()
    {
        return $this->view('admin.add_user');
    }

    /**
     * 用户编辑
     * @return mixed
     */
    public function EditUser()
    {

        if (Request::isMethod('POST')) {
            #收集信息
            $paramObj             = new stdClass();
            $paramObj->user_id         =    $this->getParam('user_id');                 //ID
            $paramObj->user_name       =    $this->getParam('user_name');               //姓名
            $paramObj->real_name       =    $this->getParam('real_name');          //真名
            $paramObj->password        =    $this->getParam('password');           //密码
            $paramObj->id_card         =    $this->getParam('id_card');            //角色
            $paramObj->mobile          =    $this->getParam('mobile');             //联系方式
            $paramObj->avatar          =    $this->getParam('avatar');             //头像
            $paramObj->status          =    $this->getParam('status');             //状态
            $paramObj->sure            =    $this->getParam('sure');
            $paramObj->sex             =    $this->getParam('sex'); //密码确认
            $paramObj->avatar_old      =    $this->getParam('avatar_old');
            $paramObj->user_type       =    $this->getParam('user_type');
            $paramObj->email           =    $this->getParam('email');
            #逻辑处理
            empty($paramObj->user_id) ?
                (AdminService::instance()->UserAdd($paramObj).
                    LogService::instance()->write(['content' => '添加用户'.$paramObj->user_name, 'type' => '个人中心'])):
                (AdminService::instance()->UserUp($paramObj).
                    LogService::instance()->write(['content' => '修改用户'.$paramObj->user_name, 'type' => '个人中心']));
            return Redirect::to('/manage_user');
        } else {
            $id = $this->getParam('user_id');
            $info = AdminService::instance()->GetUserInfo($id);
            return $this->view('admin.add_user')->with('user', $info);
        }
    }

    /**
     * 用户删除
     */
    public function DeleteUser()
    {
        #收集信息
        $aData = new stdClass();
        $aData->id = $this->getParam('id');

        $name = AdminService::instance()->GetAdminInfo($aData->id)->name;
        #逻辑操作
        $state = AdminService::instance()->DeleteAdmin($aData);
        LogService::instance()->write(['content' => '删除用户'.$name, 'type' => '个人中心']);
        $this->rest->success(['state' => $state], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }

    /**
     * 用户删除ajax返回
     */
    public function UserServiceAjax()
    {
        $info = AdminService::instance()->ManageAdmin();
        return $this->viewAjax('admin.ajaxTemplates.admin_list_part')->with('info', $info);
    }



    /**
     * 投标记录管理
     */
    public function InvestRecord(){
        $info = AdminService::instance()->InvestRecordList();
        return $this->view('admin.incest_record')->with('info',$info);
    }

    /**
     * 投资记录删除
     */
    public function DeleteInvestRecord()
    {
        #收集信息
        $paramObj = new stdClass();
        $paramObj->invest_id = $this->getParam('invest_id');
        $name = AdminService::instance()->SelectOneInvestRecord($paramObj);
        $type = $name->type == 1?"上市通":"央票通";
        $project_name = $name->project_name;
        #逻辑操作
        $state = AdminService::instance()->DeleteInvestRecord($paramObj->invest_id);
        LogService::instance()->write(['content' => '删除'.$type.'投资记录'.$project_name, 'type' => '个人中心']);
        $this->rest->success(['state' => $state], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }

    /**
     * 投资记录ajax返回
     * @return mixed
     * @author lzhp
     * @date 2016-04-04
     */
    public function AdminInvestRecordAjax()
    {
        $info = AdminService::instance()->InvestRecordList();
        return $this->viewAjax('admin.ajaxTemplates.InvestRecord_list_part')->with('info', $info);
    }


    /**
     * 报票记录管理
     */
    public function TicketRecord(){
        $info = AdminService::instance()->TicketRecordList();
        return $this->view('admin.ticket_record')->with('info',$info);
    }

    /**
 * 报票记录删除
 */
    public function DeleteTicketRecord()
    {
        #收集信息
        $paramObj = new stdClass();
        $paramObj->ticket_id = $this->getParam('ticket_id');
        #逻辑操作
        $state = AdminService::instance()->DeleteTicketRecord($paramObj->ticket_id);
        LogService::instance()->write(['content' => '删除报票记录ID为'.$paramObj->ticket_id, 'type' => '个人中心']);
        $this->rest->success(['state' => $state], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }

    /**
     * 报票记录ajax返回
     * @return mixed
     */
    public function AdminTicketRecordAjax()
    {
        $info = AdminService::instance()->TicketRecordList();
        return $this->viewAjax('admin.ajaxTemplates.ticket_list_part')->with('info', $info);
    }


    /**
     * 充值记录管理
     */
    public function RechargeRecord(){
        $info = AdminService::instance()->RechargeRecordList();
        return $this->view('admin.recharge_record')->with('info',$info);
    }

    /**
     * 充值记录删除
     */
    public function DeleteRechargeRecord()
    {
        #收集信息
        $paramObj = new stdClass();
        $paramObj->rechar_id = $this->getParam('rechar_id');
        #逻辑操作
        $state = AdminService::instance()->DeleteRechartRecord($paramObj->rechar_id);
        LogService::instance()->write(['content' => '删除充值记录ID为'.$paramObj->rechar_id, 'type' => '个人中心']);
        $this->rest->success(['state' => $state], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }

    /**
     * 充值记录ajax返回
     * @return mixed
     */
    public function AdminRechargeRecordAjax()
    {
        $info = AdminService::instance()->RechargeRecordList();
        return $this->viewAjax('admin.ajaxTemplates.rechar_list_part')->with('info', $info);
    }



    /**
     * 提现记录管理
     */
    public function WithdrawRecord(){
        $info = AdminService::instance()->WithdrawRecordList();
        return $this->view('admin.withdraw_record')->with('info',$info);
    }

    /**
     * 提现记录删除
     */
    public function DeleteWithdrawRecord()
    {
        #收集信息
        $paramObj = new stdClass();
        $paramObj->withdraw_id = $this->getParam('withdraw_id');
        #逻辑操作
        $state = AdminService::instance()->DeleteWithdrawRecord($paramObj->withdraw_id);
        LogService::instance()->write(['content' => '删除提现记录ID为'.$paramObj->withdraw_id, 'type' => '个人中心']);
        $this->rest->success(['state' => $state], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }

    /**
     * 提现记录ajax返回
     * @return mixed
     */
    public function AdminWithdrawRecordAjax()
    {
        $info = AdminService::instance()->WithdrawRecordList();
        return $this->viewAjax('admin.ajaxTemplates.withdraw_list_part')->with('info', $info);
    }


    /**
     * 用户银行卡管理
     */
    public function BankManage(){
        $info = AdminService::instance()->BankManageList();
        return $this->view('admin.bank_manage')->with('info',$info);
    }

    /**
     * 银行卡删除
     */
    public function DeleteBankManage()
    {
        #收集信息
        $paramObj = new stdClass();
        $paramObj->bank_id = $this->getParam('bank_id');
        #逻辑操作
        $state = AdminService::instance()->DeleteBankManage($paramObj->bank_id);
        LogService::instance()->write(['content' => '删除银行卡ID为'.$paramObj->bank_id, 'type' => '个人中心']);
        $this->rest->success(['state' => $state], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }

    /**
     * 银行卡ajax返回
     * @return mixed
     */
    public function AdminBankManageAjax()
    {
        $info = AdminService::instance()->BankManageList();
        return $this->viewAjax('admin.ajaxTemplates.bank_list_part')->with('info', $info);
    }



    /**
    ------------------------------------用户中心结束---------------------------------
     */

    /**
     * 日志
     * @return mixed
     */
    public function LogService()
    {
        $info = AdminService::instance()->LogService();
        return $this->view('admin.log_service')->with('info',$info);
    }
    /**
     *日志删除
     * @return mixed
     */
    public function DeleteLog()
    {
        #收集信息
        $aData = new stdClass();
        $aData->log_id         =   $this->getParam('log_id');


        #逻辑操作
        $state = AdminService::instance()->DeleteLog($aData);
        $this->rest->success(['state' => $state], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }
    /**
     * 日志ajax返回
     * @return mixed
     */
    public function LogServiceAjax()
    {
        $info = AdminService::instance()->LogService();
        return $this->viewAjax('admin.ajaxTemplates.log_list_part')->with('info', $info);
    }

    /**
    --------------------------------------关于我们-------------------------------------
     */
    /**
     * 资讯列表
     * @return mixed
     */
    public function NewsList()
    {
        $info = AdminService::instance()->NewsList();
        return $this->view('admin.news_list')->with('info',$info);
    }

    /**
     * 删除资讯
     */
    public function NewsDel()
    {
        #收集信息
        $aData = new stdClass();
        $aData->news_id         =   $this->getParam('news_id');

        $title = AdminService::instance()->GetNewsId($aData->news_id)->title;
        #逻辑操作
        $state = AdminService::instance()->NewsDel($aData);
        LogService::instance()->write(['content' => '删除资讯'.$title, 'type' => '资讯服务']);
        $this->rest->success(['state' => $state], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }
    public function NewsAjax()
    {
        $info = AdminService::instance()->NewsList();
        return $this->viewAjax('admin.ajaxTemplates.news_list_part')->with('info', $info);
    }

    public function NewsImport()
    {
        return $this->view('admin.news_import');
    }

    /**
     * 编辑资讯
     * @return mixed
     */
    public function NewsEdit()
    {
        if (Request::isMethod('POST')) {
            #收集信息
            $paramObj                     =     new stdClass();
            $paramObj->news_id            =     $this->getParam('news_id');            //资讯id
            $paramObj->title              =     $this->getParam('title');              //资讯标题
            $paramObj->author             =     $this->getParam('author');             //作者
            $paramObj->source             =     $this->getParam('source');             //来源
            $paramObj->type               =     $this->getParam('type');               //咨询类型
            $paramObj->content            =     $this->getParam('content');            //内容

            #逻辑操作
            empty($paramObj->news_id) ?
                (AdminService::instance()->NewsAdd($paramObj).
                    LogService::instance()->write(['content' => '资讯添加'.$paramObj->title, 'type' => '资讯服务'])):
                (AdminService::instance()->NewsUp($paramObj).
                    LogService::instance()->write(['content' => '资讯修改'.$paramObj->title, 'type' => '资讯服务']));
            return Redirect::to('/news_list');
        } else {
            $news_id  = $this->getParam('news_id');
            $info = AdminService::instance()->GetNewsId($news_id);
            return $this->view('admin.news_import')->with('news', $info);
        }
    }

    /**
     * 合作伙伴列表
     * @return mixed
     */
    public function PartnerList()
    {
        $info = AdminService::instance()->PartnerList();
        return $this->view('admin.partner_list')->with('info',$info);
    }

    public function PartnerAdd()
    {
        return $this->view('admin.partner_add');
    }

    /**
     * 合作伙伴删除
     */
    public function PartnerDel()
    {
        #收集信息
        $aData = new stdClass();
        $aData->partner_id         =   $this->getParam('partner_id');

        $partner_name = AdminService::instance()->GetPartnerId($aData->partner_id)->partner_name;
        #逻辑操作
        $state = AdminService::instance()->PartnerDel($aData);
        LogService::instance()->write(['content' => '合作伙伴删除'.$partner_name, 'type' => '合作伙伴管理']);
        $this->rest->success(['state' => $state], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }

    /**
     * 合作伙伴编辑
     * @return mixed
     */
    public function PartnerEdit()
    {
        if (Request::isMethod('POST')) {
            #收集信息
            $paramObj                     =     new stdClass();
            $paramObj->partner_id         =     $this->getParam('partner_id');         //合作伙伴id
            $paramObj->partner_name       =     $this->getParam('partner_name');       //伙伴名称
            $paramObj->introduce          =     $this->getParam('introduce');          //简介
            $paramObj->url                =     $this->getParam('url');                //网站地址

            #逻辑操作
            empty($paramObj->partner_id) ?
                (AdminService::instance()->PartnerAdd($paramObj).
                    LogService::instance()->write(['content' => '合作伙伴添加'.$paramObj->partner_name, 'type' => '合作伙伴'])):
                (AdminService::instance()->PartnerUp($paramObj).
                    LogService::instance()->write(['content' => '合作伙伴修改'.$paramObj->partner_name, 'type' => '合作伙伴']));
            return Redirect::to('/partner_list');
        } else {
            $partner_id  = $this->getParam('partner_id');
            $info = AdminService::instance()->GetPartnerId($partner_id);
            return $this->view('admin.partner_add')->with('partner', $info);
        }

    }

    /**
     * ajax返回
     * @return mixed
     */
    public function PartnerAjax()
    {
        $info = AdminService::instance()->PartnerList();
        return $this->viewAjax('admin.ajaxTemplates.partner_list_part')->with('info', $info);
    }


    /**
     * 团队列表
     * @return mixed
     */
    public function TeamList()
    {
        $info = AdminService::instance()->TeamList();
        return $this->view('admin.team_list')->with('info',$info);
    }
    public function TeamAdd()
    {
        return $this->view('admin.team_add');
    }

    /**
     * 团队删除
     */
    public function TeamDel()
    {
        #收集信息
        $aData = new stdClass();
        $aData->team_id         =   $this->getParam('team_id');

        $team_name = AdminService::instance()->GetTeamId($aData->team_id)->team_name;
        #逻辑操作
        $state = AdminService::instance()->TeamDel($aData);
        LogService::instance()->write(['content' => '团队删除'.$team_name, 'type' => '团队管理']);
        $this->rest->success(['state' => $state], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }

    /**
     * ajax返回
     * @return mixed
     */
    public function TeamAjax()
    {
        $info = AdminService::instance()->TeamList();
        return $this->viewAjax('admin.ajaxTemplates.team_list_part')->with('info', $info);
    }

    /**
     * 团队编辑
     * @return mixed
     */
    public function TeamEdit()
    {
        if (Request::isMethod('POST')) {
            #收集信息
            $paramObj                        =     new stdClass();
            $paramObj->team_id               =     $this->getParam('team_id');              //团队ID
            $paramObj->team_name             =     $this->getParam('team_name');            //成员名称
            $paramObj->team_position         =     $this->getParam('team_position');        //成员职位
            $paramObj->team_department       =     $this->getParam('team_department');      //部门名称
            $paramObj->introduce             =     $this->getParam('introduce');            //介绍

            #逻辑操作
            empty($paramObj->team_id) ?
                (AdminService::instance()->TeamAdd($paramObj).
                    LogService::instance()->write(['content' => '团队添加'.$paramObj->team_name, 'type' => '团队管理'])):
                (AdminService::instance()->TeamUp($paramObj).
                    LogService::instance()->write(['content' => '团队修改'.$paramObj->team_name, 'type' => '团队管理']));
            return Redirect::to('/team_list');
        } else {
            $team_id  = $this->getParam('team_id');
            $info = AdminService::instance()->GetTeamId($team_id);
            return $this->view('admin.team_add')->with('team', $info);
        }
    }


    /**
     * 招聘列表
     * @return mixed
     */
    public function RecruitList()
    {
        $info = AdminService::instance()->RecruitList();
        return $this->view('admin.recruit_list')->with('info',$info);
    }

    public function RecruitAdd()
    {
        return $this->view('admin.recruit_add');
    }

    /**
     * 招聘删除
     */
    public function RecruitDel()
    {
        #收集信息
        $aData = new stdClass();
        $aData->recruit_id        =   $this->getParam('recruit_id');

        $recruit_position = AdminService::instance()->GetRecruitId($aData->recruit_id)->recruit_position;
        #逻辑操作
        $state = AdminService::instance()->RecruitDel($aData);
        LogService::instance()->write(['content' => 'z招聘删除'.$recruit_position, 'type' => '招聘管理']);
        $this->rest->success(['state' => $state], ErrorCodeEnum::STATUS_SUCCESS, '刪除成功！');
    }

    /**
     * ajax返回
     * @return mixed
     */
    public function RecruitAjax()
    {
        $info = AdminService::instance()->RecruitList();
        return $this->viewAjax('admin.ajaxTemplates.recruit_list_part')->with('info', $info);
    }

    public function RecruitEdit()
    {
        if (Request::isMethod('POST')) {
            #收集信息
            $paramObj                        =     new stdClass();
            $paramObj->recruit_id            =     $this->getParam('recruit_id');                  //招聘ID
            $paramObj->recruit_position      =     $this->getParam('recruit_position');            //招聘职位
            $paramObj->duty                  =     $this->getParam('duty');                        //岗位职责
            $paramObj->requirement           =     $this->getParam('requirement');                 //岗位要求
            $paramObj->contact               =     $this->getParam('contact');                     //联系方式

            #逻辑操作
            empty($paramObj->recruit_id   ) ?
                (AdminService::instance()->RecruitAdd($paramObj).
                    LogService::instance()->write(['content' => '招聘添加'.$paramObj->recruit_position, 'type' => '招聘管理'])):
                (AdminService::instance()->RecruitUp($paramObj).
                    LogService::instance()->write(['content' => '招聘修改'.$paramObj->recruit_position, 'type' => '招聘管理']));
            return Redirect::to('/recruit_list');
        } else {
            $recruit_id  = $this->getParam('recruit_id');
            $info = AdminService::instance()->GetRecruitId($recruit_id);
            return $this->view('admin.recruit_add')->with('recruit', $info);
        }
    }
    /**
    --------------------------------------关于我们结束-------------------------------------
     */

}





